From 579971e1bd91f74329f43178c3edeffd79778664 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 21 Oct 2014 08:56:43 -0700 Subject: [PATCH] Compile deps with optimizations for benches Previously only the local package was erroneously compiled with optimizations. Closes #728 --- src/cargo/ops/cargo_rustc/context.rs | 5 +++-- tests/test_cargo_bench.rs | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index e3762012f..c0a36a757 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -276,13 +276,14 @@ impl<'a, 'b> Context<'a, 'b> { pub fn is_relevant_target(&self, target: &Target) -> bool { target.is_lib() && match self.env { - "doc" | "test" | "bench" => target.get_profile().is_compile(), + "doc" | "test" => target.get_profile().is_compile(), // doc-all == document everything, so look for doc targets and // compile targets in dependencies "doc-all" => target.get_profile().is_compile() || (target.get_profile().get_env() == "doc" && target.get_profile().is_doc()), - _ => target.get_profile().get_env() == self.env, + _ => target.get_profile().get_env() == self.env && + !target.get_profile().is_test(), } } } diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index 6d009c0d4..d1d4da795 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -655,11 +655,11 @@ test!(bench_dylib { execs().with_status(0) .with_stdout(format!("\ {compiling} bar v0.0.1 ({dir}) -{running} [..] +{running} [..] --opt-level 3 [..] {compiling} foo v0.0.1 ({dir}) -{running} [..] -{running} [..] -{running} [..] +{running} [..] --opt-level 3 [..] +{running} [..] --opt-level 3 [..] +{running} [..] --opt-level 3 [..] {running} [..]target[..]release[..]bench-[..] running 1 test -- 2.30.2